{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "ename": "ArgumentError",
     "evalue": "Could not parse rfc1738 URL from string 'server=127.0.0.1;uid=root;pwd=12345;database=test'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mArgumentError\u001b[0m                             Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-1-f2ae36c45c30>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      2\u001b[0m \u001b[0msqlpath\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'server=127.0.0.1;uid=root;pwd=12345;database=test'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0;31m#'sqlite:///db.sql'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mengine\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcreate_engine\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msqlpath\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mecho\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      5\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0msqlalchemy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mext\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdeclarative\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdeclarative_base\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      6\u001b[0m \u001b[0mBase\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdeclarative_base\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/sbadusa/anaconda2/lib/python2.7/site-packages/sqlalchemy/engine/__init__.pyc\u001b[0m in \u001b[0;36mcreate_engine\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m    385\u001b[0m     \u001b[0mstrategy\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'strategy'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdefault_strategy\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    386\u001b[0m     \u001b[0mstrategy\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mstrategies\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstrategies\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstrategy\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 387\u001b[0;31m     \u001b[0;32mreturn\u001b[0m \u001b[0mstrategy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcreate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    388\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    389\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/sbadusa/anaconda2/lib/python2.7/site-packages/sqlalchemy/engine/strategies.pyc\u001b[0m in \u001b[0;36mcreate\u001b[0;34m(self, name_or_url, **kwargs)\u001b[0m\n\u001b[1;32m     48\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0mcreate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname_or_url\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     49\u001b[0m         \u001b[0;31m# create url.URL object\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 50\u001b[0;31m         \u001b[0mu\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0murl\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmake_url\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname_or_url\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     51\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     52\u001b[0m         \u001b[0mplugins\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mu\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_instantiate_plugins\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/sbadusa/anaconda2/lib/python2.7/site-packages/sqlalchemy/engine/url.pyc\u001b[0m in \u001b[0;36mmake_url\u001b[0;34m(name_or_url)\u001b[0m\n\u001b[1;32m    192\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    193\u001b[0m     \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname_or_url\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mutil\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstring_types\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 194\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0m_parse_rfc1738_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname_or_url\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    195\u001b[0m     \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    196\u001b[0m         \u001b[0;32mreturn\u001b[0m \u001b[0mname_or_url\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/sbadusa/anaconda2/lib/python2.7/site-packages/sqlalchemy/engine/url.pyc\u001b[0m in \u001b[0;36m_parse_rfc1738_args\u001b[0;34m(name)\u001b[0m\n\u001b[1;32m    241\u001b[0m     \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    242\u001b[0m         raise exc.ArgumentError(\n\u001b[0;32m--> 243\u001b[0;31m             \"Could not parse rfc1738 URL from string '%s'\" % name)\n\u001b[0m\u001b[1;32m    244\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    245\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mArgumentError\u001b[0m: Could not parse rfc1738 URL from string 'server=127.0.0.1;uid=root;pwd=12345;database=test'"
     ]
    }
   ],
   "source": [
    "from sqlalchemy import create_engine\n",
    "sqlpath = 'sqlite:///server=127.0.0.1;uid=root;pwd=12345;database=test'\n",
    "#'sqlite:///db.sql'\n",
    "engine = create_engine(sqlpath, echo=True)\n",
    "from sqlalchemy.ext.declarative import declarative_base\n",
    "Base = declarative_base()\n",
    "\n",
    "from sqlalchemy import Column, Integer, String\n",
    "class Post(Base):\n",
    "    __tablename__ = 'posts'\n",
    "    id = Column(Integer, primary_key=True)\n",
    "    topic_content = Column(String)\n",
    "    post_content = Column(String)\n",
    "    post_authar = Column(String)\n",
    "    url = Column(String)\n",
    "    def __repr__(self):\n",
    "        return \"<Post(topic_content='%s', post_content='%s', post_authar='%s', url='%s')>\" % (self.topic_content, self.post_content, self.post_authar, self.url)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2017-11-25 04:20:59,270 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1\n",
      "2017-11-25 04:20:59,272 INFO sqlalchemy.engine.base.Engine ()\n",
      "2017-11-25 04:20:59,274 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1\n",
      "2017-11-25 04:20:59,276 INFO sqlalchemy.engine.base.Engine ()\n",
      "2017-11-25 04:20:59,278 INFO sqlalchemy.engine.base.Engine PRAGMA table_info(\"posts\")\n",
      "2017-11-25 04:20:59,280 INFO sqlalchemy.engine.base.Engine ()\n",
      "2017-11-25 04:20:59,283 INFO sqlalchemy.engine.base.Engine \n",
      "CREATE TABLE posts (\n",
      "\tid INTEGER NOT NULL, \n",
      "\ttopic_content VARCHAR, \n",
      "\tpost_content VARCHAR, \n",
      "\tpost_authar VARCHAR, \n",
      "\turl VARCHAR, \n",
      "\tPRIMARY KEY (id)\n",
      ")\n",
      "\n",
      "\n",
      "2017-11-25 04:20:59,284 INFO sqlalchemy.engine.base.Engine ()\n",
      "2017-11-25 04:20:59,287 INFO sqlalchemy.engine.base.Engine COMMIT\n"
     ]
    }
   ],
   "source": [
    "Base.metadata.create_all(engine)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2017-11-25 04:18:06,991 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)\n",
      "2017-11-25 04:18:06,993 INFO sqlalchemy.engine.base.Engine SELECT posts.id AS posts_id, posts.topic_content AS posts_topic_content, posts.post_content AS posts_post_content, posts.post_authar AS posts_post_authar, posts.url AS posts_url \n",
      "FROM posts ORDER BY posts.id\n",
      "2017-11-25 04:18:06,995 INFO sqlalchemy.engine.base.Engine ()\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. bitcoin and paypal   send me the info of the hack to my email @ darkelite187@secmail.pro\n",
      "3. bitcoin and paypal   send me the info of the hack to my email @ darkelite187@secmail.pro\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. Hello mr.dark I am new here in your site just wondering how I can dowload these zip files in your brotherhood forum?I want to learn about hacking.Thanks in advance.\n",
      "3. Hello mr.dark I am new here in your site just wondering how I can dowload these zip files in your brotherhood forum?I want to learn about hacking.Thanks in advance.\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. How do I stop my real name appearing on any financial transactions?\n",
      "3. How do I stop my real name appearing on any financial transactions?\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. How do I use bitcoin, because my bank need to confirm the payment by telephone and I don't want that to happen?\n",
      "3. How do I use bitcoin, because my bank need to confirm the payment by telephone and I don't want that to happen?\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. i be setting up paypal soon can u email me me with the info @ darkelite187@secmail.pro thanks\n",
      "3. i be setting up paypal soon can u email me me with the info @ darkelite187@secmail.pro thanks\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. oh btw download the new tool i posted up last night\n",
      "3. oh btw download the new tool i posted up last night\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. i have debit card details with owners name, the first five and last four digits, expiration date  if you have any means by which we can use the to make money  let's discuss about it\n",
      "3. i have debit card details with owners name, the first five and last four digits, expiration date  if you have any means by which we can use the to make money  let's discuss about it\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. buy bitcoins with it lol\n",
      "3. buy bitcoins with it lol\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n",
      "------------------------------\n",
      "1. Re: Message for darkelite187\n",
      "2. come on I also got means to pos data on sales too\n",
      "3. come on I also got means to pos data on sales too\n",
      "4. http://wqekut2pocn45hwp.onion/forums/viewtopic.php?f=18&t=131&start=10\n"
     ]
    }
   ],
   "source": [
    "from sqlalchemy.orm import sessionmaker\n",
    "Session = sessionmaker(bind=engine)\n",
    "session = Session()\n",
    "for instance in session.query(Post).order_by(Post.id):\n",
    "    print '------------------------------'\n",
    "    print '1. ' + instance.topic_content\n",
    "    print '2. ' + instance.post_content\n",
    "    print '3. ' + instance.post_authar\n",
    "    print '4. ' + instance.url"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
